﻿using gl_SMT.View;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using static DataAcquisition.CustomControls.DeviceType;

namespace DataAcquisition.CustomControls
{
    /// <summary>
    /// DeviceType.xaml 的交互逻辑
    /// </summary>
    public partial class DeviceType : UserControl
    {
        public DeviceType()
        {
            InitializeComponent();
            this.Loaded += DeviceType_Loaded;
        }
        #region   变量
        /// <summary>
        /// 设备名称
        /// </summary>
        public string DeviceName { get; set; }
        /// <summary>
        /// 设备数量
        /// </summary>
        public string DeviceNumber { get; set; }
        /// <summary>
        /// 生产编号
        /// </summary>
        public string ProductionNumber { get; set; }
        /// <summary>
        /// 警报数量
        /// </summary>
        public string AlmNumber { get; set; }
        public string OutPut { get; set; }
        public delegate void CloseMainWindow();
        public CloseMainWindow closeMainWindow;

        #endregion

        private void DeviceType_Loaded(object sender, RoutedEventArgs e)
        {
            btn_DeviceName.Content = DeviceName;
            txt_DeviceNumber.Text = DeviceNumber;
        }

        private void btn_DeviceName_Click(object sender, RoutedEventArgs e)
        {
            Button Btn = (Button)sender;
            VariableStorage.SelectType = DeviceName;
            VariableStorage.NumberMachines = GetDNumber(Btn.Content.ToString());
            closeMainWindow();
            if (Btn.Content.ToString() == "GKG自动印刷机") VariableStorage.gkg_Running = true;
            if (Btn.Content.ToString() == "回流焊接机") VariableStorage.hl_Running = true;
            if (Btn.Content.ToString() == "雅马哈贴片机") VariableStorage.ymh_Running = true;
            if (Btn.Content.ToString() == "JUKI贴片机") VariableStorage.juki_Running = true;
        }

        public int GetDNumber(string Name)
        {
            int Number = 0;
            switch (Name)
            {
                case "GKG自动印刷机":
                    return Number = 12;
                case "点精点胶机":
                    return Number = 1;
                case "除湿房":
                    return Number = 6;
                case "富士贴片机":
                    return Number = 6;
                case "回流焊接机":
                    return Number = 3;
                case "丝印印刷机":
                    return Number = 1;
                case "雅马哈贴片机":
                    return Number = 6;
                case "JUKI贴片机":
                    return Number = 2;
                default:
                    return Number;
            }
        }
    }
}
